package com.lcz.mytest.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.lcz.mytest.R;
import com.lcz.mytest.fragment.FragmentFactory;
import com.lcz.mytest.utils.UiUtils;

import java.sql.SQLOutput;

/**
 * Created by Administrator on 2016/4/20.
 */
public class FragmentAdapter extends FragmentStatePagerAdapter {
    private String[] tab_names = null; // 标签的名字

    public FragmentAdapter(FragmentManager fm,String[] tab_names) {
        super(fm);
        this.tab_names = tab_names;
    }

    // 每个条目返回的fragment
    @Override
    public Fragment getItem(int position) {
        // 通过Fragment工厂 生产Fragment
        return FragmentFactory.createFragment(position);
    }

    // 一共有几个条目
    @Override
    public int getCount() {
        return tab_names.length;
    }

    // 返回每个条目的标题
    @Override
    public CharSequence getPageTitle(int position) {
        return tab_names[position];
    }

}
